package com.tuling;

import java.io.IOException;

import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;

/**
 * 注册中心
 * 
 * @author wangningbo
 *
 */
public class ZookeeperRegister {
	public static final String ROOT = "/kf";

	private static final String CONN_STR = "120.27.193.222:2181,120.27.194.173:2181,47.97.22.33:2181";

	private static final Integer SESSION_TIMEOUT = 6000;

	public ZookeeperRegister() {
		
	}

	/**
	 * 获取zk链接
	 */
	public ZooKeeper getConnection(Watcher watcher) {
		ZooKeeper zk = null;
		try {
			zk = new ZooKeeper(CONN_STR, SESSION_TIMEOUT, watcher);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return zk;
	}
}
